package com.wuyan.locationdog.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.MsgBeanContent
import com.arcsoft.commonbase.ext.gone
import com.arcsoft.commonbase.ext.loadImageCircleCar
import com.arcsoft.commonbase.ext.radius
import com.arcsoft.commonbase.ext.visibleOrGone
import com.blankj.utilcode.util.SizeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R


class MsgListAdapter(@LayoutRes layoutResId: Int, data: MutableList<MsgBeanContent>?) :
    BaseQuickAdapter<MsgBeanContent, BaseViewHolder>(layoutResId, data) {

    override fun convert(holder: BaseViewHolder, item: MsgBeanContent) {
        //noticeType 消息通知类型1报警 2待接受共享 3已接受共享 4共享被接受 5已取消
        holder.apply {
            getView<TextView>(R.id.createTime).text = item.createTime
            getView<View>(R.id.ifRead).apply {
                radius(SizeUtils.dp2px(3F).toFloat())
                visibleOrGone(!item.ifRead)
            }
///用户消息类型1报警 2系统通知
            if (item.billType == 1) {
                getView<TextView>(R.id.alarmTypeDesc).text = item.deviceName
                getView<TextView>(R.id.alarmAddress).text = item.alarmTypeDesc
            } else {
                getView<TextView>(R.id.alarmAddress).text = item.noticeContent
            }
            ///用户消息类型1报警 2共享通知 3团队邀请通知 4指令通知
            if (item.billType == 1) {
                getView<TextView>(R.id.alarmTypeDesc).text = item.deviceName

                getView<ImageView>(R.id.icon).loadImageCircleCar(item.dogImg)

            } else if (item.billType == 2) {

                getView<TextView>(R.id.alarmTypeDesc).text = "共享通知"

                getView<ImageView>(R.id.icon).setImageResource(R.mipmap.msg_share)
            } else if (item.billType == 3) {

                getView<TextView>(R.id.alarmTypeDesc).text = "团队通知"

                getView<ImageView>(R.id.icon).setImageResource(R.mipmap.msg_team)
            } else if (item.billType == 4) {

                getView<TextView>(R.id.alarmTypeDesc).text = "指令通知"

                getView<ImageView>(R.id.icon).setImageResource(R.mipmap.msg_cmd)
            }


        }
    }
}


